<?php

/**
 * @common.php
 * Common functions that webPanel modules can reference.
 *
 */

/**
 * Limits given array by given boundaries
 *
 * @param $array_to_lim
 *	array to be limited
 *
 * @param $low_lim
 *	first position to be returned
 *
 * @param $n
 *	result array length
 *
 * @return
 *	limited array
 */
function limit($array_to_lim, $low_lim, $n)
{
	if (($low_lim+$n > count($array_to_lim)) OR ($n<0))
		$n = count($array_to_lim)-$low_lim;
	$array_out = array();
	$j=0;
	for ($i=$low_lim; $i<$low_lim+$n; $i++)
	{
		$array_out[$j] = $array_to_lim[$i];
		$j++;
	}
	return $array_out;
}

?>
